package cn.hdu.liang.generics;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

public class Exam6<T> {
    private ArrayList<T> storage = new ArrayList<>();
    private Random random = new Random(47);

    public void add(T item) {
        storage.add(item);
    }

    public T select() {
        return storage.get(random.nextInt(storage.size()));
    }

    public static void main(String[] args) {
        Exam6<Integer> rs = new Exam6<>();
        Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9).forEach(rs::add);
        for(int i = 0; i < 11; i++) {
            System.out.print(rs.select() + " ");
        }
    }
}
